From 9763103317f6b47157d49f71755a51a877ffd782 Mon Sep 17 00:00:00 2001 From: "cl349@firebug.cl.cam.ac.uk" Date: Fri, 9 Sep 2005 16:06:04 +0000 Subject: [PATCH] Always start transactions on an existing path. Signed-off-by: Christian Limpach --- tools/python/xen/xend/xenstore/xstransact.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tools/python/xen/xend/xenstore/xstransact.py b/tools/python/xen/xend/xenstore/xstransact.py index 68e3998fb5..0be418401a 100644 --- a/tools/python/xen/xend/xenstore/xstransact.py +++ b/tools/python/xen/xend/xenstore/xstransact.py @@ -4,6 +4,7 @@ # Public License. See the file "COPYING" in the main directory of # this archive for more details. +import errno import threading from xen.lowlevel import xs @@ -18,9 +19,18 @@ def xshandle(): class xstransact: def __init__(self, path): + self.in_transaction = False self.path = path.rstrip("/") - xshandle().transaction_start(path) - self.in_transaction = True + while True: + try: + xshandle().transaction_start(path) + self.in_transaction = True + return + except RuntimeError, ex: + if ex.args[0] == errno.ENOENT and path != "/": + path = "/".join(path.split("/")[0:-1]) or "/" + else: + raise def __del__(self): if self.in_transaction: -- 2.30.2